package model.environmentConfig;

import java.awt.Point;

public class NodeRectangle {
	private final static double DEFAULT_WIDTH=50;
	private final static double DEFAULT_HEIGHT=100;
	
	private double x;
	private double y;
	
	private double width;
	private double height;
	
	public NodeRectangle(){
		this(0.0, 0.0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
	}
	
	public NodeRectangle(int x, int y, int width, int height){
		this(new Double(x), new Double(y), new Double(width), new Double(height));
	}
	
	public NodeRectangle(double x, double y, double width, double height){
		this.x=x;
		this.y=y;
		this.width=width;
		this.height=height;
	}
	
	public void translate(double dx, double dy){
		this.x+=dx;
		this.y+=dy;
	}
	
	public boolean contains(Point point){
		return(point.x>=this.x
			&& point.x<=this.x+this.width
			&& point.y>=this.y
			&& point.y<=this.y+this.height);
	}
	
	public Point getCenter(){
		Point center=new Point();
		center.setLocation(x+width/2, y+height/2);
		return(center);
	}
	
	public double getX(){
		return(x);
	}
	
	public void setX(double x){
		this.x=x;
	}
	public double getY(){
		return(y);
	}
	
	public void setY(double y){
		this.y=y;
	}
	
	public double getWidth(){
		return(width);
	}
	
	public void setWidth(double width){
		this.width=width;
	}
	
	public double getHeight(){
		return(height);
	}
	
	public void setHeight(double height){
		this.height=height;
	}
}
